package com.cqc.intentaction01;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.provider.Settings;
import android.provider.Telephony;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "MainActivity";
    @BindView(R.id.btn1)
    Button btn1;
    @BindView(R.id.btn2)
    Button btn2;
    @BindView(R.id.btn3)
    Button btn3;
    @BindView(R.id.btn4)
    Button btn4;
    @BindView(R.id.btn5)
    Button btn5;
    @BindView(R.id.btn6)
    Button btn6;
    @BindView(R.id.btn7)
    Button btn7;
    @BindView(R.id.btn8)
    Button btn8;
    @BindView(R.id.btn9)
    Button btn9;
    @BindView(R.id.btn10)
    Button btn10;
    @BindView(R.id.btn11)
    Button btn11;
    @BindView(R.id.btn12)
    Button btn12;
    @BindView(R.id.btn13)
    Button btn13;
    @BindView(R.id.btn14)
    Button btn14;
    @BindView(R.id.btn15)
    Button btn15;
    @BindView(R.id.btn16)
    Button btn16;
    @BindView(R.id.btn20)
    Button btn20;
    @BindView(R.id.btn21)
    Button btn21;
    @BindView(R.id.btn22)
    Button btn22;
    @BindView(R.id.btn23)
    Button btn23;
    @BindView(R.id.btn24)
    Button btn24;
    @BindView(R.id.btn25)
    Button btn25;
    private Intent intent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);

        intent = new Intent();
    }

    @OnClick({R.id.btn1, R.id.btn2, R.id.btn3, R.id.btn4, R.id.btn5, R.id.btn6, R.id.btn7, R.id.btn8, R.id.btn9, R.id.btn10, R.id.btn11, R.id.btn12, R.id.btn13, R.id.btn14, R.id
            .btn15, R.id.btn16, R.id.btn20, R.id.btn21, R.id.btn22, R.id.btn23, R.id.btn24, R.id.btn25})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn1:
                intent.setAction(Intent.ACTION_CALL);
                intent.setData(Uri.parse("tel:1580962885"));
                break;
            case R.id.btn2:
                intent.setAction(Intent.ACTION_DIAL);
                intent.setData(Uri.parse("tel:1580962885"));
                break;
            case R.id.btn3:
                break;
            case R.id.btn4:
                break;
            case R.id.btn5:
                intent.setAction(Intent.ACTION_CALL_BUTTON);
                break;
            case R.id.btn6:
                intent.setAction(Intent.ACTION_GET_CONTENT);
                intent.setType("image/*");
                Intent intentChooser = intent.createChooser(intent, null);
                startActivityForResult(intentChooser, 101);
                break;
            case R.id.btn7:
                intent.setAction(Intent.ACTION_GET_CONTENT);
                intent.setType("video/*");
                Intent intentChooser1 = intent.createChooser(intent, null);
                startActivityForResult(intentChooser1, 101);
                break;
            case R.id.btn8:
                intent.setAction(Intent.ACTION_VIEW);
                Uri uri = Uri.parse("tel:15153510997");
                intent.setData(uri);
                break;
            case R.id.btn9:
                intent.setAction(Intent.ACTION_VIEW);
                Uri uri9 = Uri.parse("https://www.baidu.com/");
                intent.setData(uri9);
                break;
            case R.id.btn10://报错
                intent.setAction(Intent.ACTION_VIEW);
                Uri uri10 = Uri.parse("geo:39.916927,116.403119");
                intent.setData(uri10);
                break;
            case R.id.btn11:
                intent.setAction(Intent.ACTION_VIEW);
                Uri uri11 = Uri.parse("file:///sdcard/media.mp4");
                intent.setData(uri11);
                intent.setType("video/*");
                break;
            case R.id.btn12:
                intent.setAction(Intent.ACTION_VIEW);
                intent.putExtra("sms_body", "信息内容...");
                intent.setType("vnd.android-dir/mms-sms");
                break;
            case R.id.btn13:
                Uri uri13 = Uri.parse("smsto:15800962885");
                intent.setData(uri13);
                intent.setAction(Intent.ACTION_SENDTO);
                intent.putExtra("sms_body", "短信内容");
                break;
            case R.id.btn14:
                break;
            case R.id.btn15:
                break;
            case R.id.btn16:
                intent.setAction(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                break;
            case R.id.btn20:

                break;
            case R.id.btn21:
                Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                Uri uri21 = Uri.parse("content://mms/scrapSpace");
                intent.putExtra(MediaStore.EXTRA_OUTPUT, uri21);
                startActivityForResult(intent, 102);
                break;
            case R.id.btn22:
                break;
            case R.id.btn23:
                break;
            case R.id.btn24:
                break;
            case R.id.btn25:
                break;
        }
        startActivity(intent);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        String dataString = data.getDataString();
        Log.d(TAG, "dataString=" + dataString);
        switch (requestCode) {
            case 100:

                break;
            case 101:

                break;
        }
    }
}
